import config from '../../config/index'

export interface Fail {
  code: number,
  message: string,
}

interface Success extends Fail {
  data: Array<object>
}

class Back {
  public static success = (data: Array<object> = [], code?: number, message?: string): Success => {
    return { code: code || config.status.success, message: message || 'success', data }
  }

  public static fail = ( message: string = 'fail', code?: number,): Fail => {
    return { code: code || config.status.fail, message }
  }
}

export default Back
